package DVIAQVIMIV;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;

import ME.VPC.M.app.App;
import test.java.interfaces.test.CommonTestInition;

//import PEU.P.image.ReadWritePng;
/*
 * 个人著作权人, 作者 罗瑶光, 浏阳
 * yaoguangluo@outlook.com, 313699483@qq.com, 2080315360@qq.com,
 * (lyg.tin@gmail.com2018年回国后因国内G网屏蔽不再使用）
 * 15116110525-浏阳德塔软件开发有限公司-创始人-法人-总经理-永久非盈利-
 * 430181198505250014, G24402609, EB0581342
 * 204925063, 389418686, F2406501, 0626136
 * 湖南省 浏阳市 集里街道 神仙坳社区 大塘冲一段路 208号 阳光家园别墅小区 第十栋别墅 第三层
 * */

public class DoDeciphering_17 {
	public String outputFilePath;

	public void setOutputFilePath(String outputPath) {
		outputFilePath = outputPath;
	}

	public void imageDeciphering(String indexFileCategoryPath, App NE) {
		//1 输入文件夹字符串
		File file = new File(indexFileCategoryPath);
		doInerFiles(file, NE);
		//2 遍历文件夹下所有图片
		//3 每个图片进行训练取值
		//4 训练值进行记录
	}

	public void doInerFiles(File file, App NE) {
		try {
			if (file.isDirectory()) {
				File[] files = file.listFiles();
				for (File currentFile : files) {
					doInerFiles(currentFile, NE);
				}
			} else {
				if (file.isFile()) {
					if (null != file.getPath()) {
						String filePath = file.getPath();
						if (filePath.contains(".jpg") || filePath
							.contains(".jpeg") || filePath.contains(
								".png")) {
							//if(filePath.contains(".png")) {
							//3 每个图片进行训练取值
							int[][][] getSkinBy = new GetSkinBy()
								.getSkinBy(filePath);
							int[][][] doPDEofSkin = new DoPDEofSkin()
								.doPDEofSkin_AOPM_VECS_IDUQ_TXH(
									getSkinBy, 95, NE);
							//new	ReadWritePng().writePNG("C:/Users/yaogu
							///Desktop/project/开源门户/deciphering/F_DB.jpg", doPDEofSkin);
							double[] getStatisticCount = new GetStatisticCount()
								.getStatisticCount(doPDEofSkin, 10, 2,
									8);
							double[] getStatisticRatio = new GetStatisticRatio()
								.getStatisticRatio(getStatisticCount);
							//4 训练值进行记录
							File fileOut = new File(outputFilePath);
							//我不建议用数据库, 建议用txt 行操作即可.
							//以后训练数据比较完善准确了, 再用德塔数据库.
							FileWriter fileWriter = null;
							fileWriter = new FileWriter(fileOut,
								true);
							fileWriter.write("f>" + file.getName());
							for (int i = 0; i < getStatisticRatio.length; i++) {
								fileWriter.write(">d>"
									+ getStatisticRatio[i] * 10000);
							}
							fileWriter.write("\r\n");
							fileWriter.close();
						}
					}
				}
			}
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	public static void main(String[] args) {
		CommonTestInition commonTestInition = new CommonTestInition();
		commonTestInition.initEnvironment("去弹窗组件流测试");
		DoDeciphering_17 doDeciphering = new DoDeciphering_17();
		doDeciphering.setOutputFilePath(
			"C:/Users/yaogu/Desktop/project"
				+ "/开源门户/deciphering/F_DB6_17.txt");
		doDeciphering.imageDeciphering("D:/bu20210606"
			+ "/搜索图片/搜索图片/pgSearch", commonTestInition.NE);
		commonTestInition.endEnvironment();

	}
}
